package o;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import java.util.HashSet;
import java.util.Set;
import o.ewm.h;
import o.ewm.j;
import o.ewm.n;

public class dws {
    private View ˋ;
    private cku ˏ;
    private d ॱ;

    public interface d {
        void aj_();

        void ak_();
    }

    public dws(Context context, String str, String str2, d dVar) {
        CharSequence ˏ = ˏ(context, str);
        if (ˏ != null) {
            this.ˏ = cku.ˋ(null, ˏ);
            this.ˋ = LayoutInflater.from(context).inflate(h.ˏﹳ, null);
            int ˎ = ewb.ˎ((Activity) this.ˋ.getContext());
            this.ˋ.setPadding(ˎ, 0, ˎ, 0);
            this.ˏ.ˊ(this.ˋ);
            this.ˏ.ॱ(-2, context.getString(n.ˊˈ));
            this.ˏ.ॱ(-1, context.getString(n.ﹳˏ));
            this.ॱ = dVar;
            ˎ(context, str, str2);
        }
    }

    public static String ˎ(Context context, String str) {
        if (context == null) {
            return null;
        }
        Resources resources = context.getResources();
        int identifier = resources.getIdentifier(str, "string", context.getPackageName());
        if (identifier != 0) {
            return resources.getString(identifier);
        }
        return null;
    }

    public void ˏ(Context context) {
        if (this.ˏ != null && !this.ˏ.isAdded()) {
            this.ˏ.ˋ(context, "deeplinkDialog");
        }
    }

    private String ˏ(Context context, String str) {
        String ˎ = ˎ(context);
        String ˊ = ˊ(context, str);
        if (ˎ == null || ˊ == null) {
            return null;
        }
        return context.getString(n.ᐝʻ, new Object[]{ˎ, ˊ});
    }

    private String ˊ(Context context, String str) {
        PackageManager packageManager = context.getPackageManager();
        try {
            CharSequence applicationLabel = packageManager.getApplicationLabel(packageManager.getApplicationInfo(str, DnsConfig.MAX_CACHE_ENTRIES));
            if (applicationLabel != null) {
                return applicationLabel.toString();
            }
        } catch (NameNotFoundException e) {
            Logger.e("DeeplinkJumpDialog", "NameNotFoundException: " + e.toString());
        }
        return null;
    }

    private String ˎ(Context context) {
        if (context == null) {
            return null;
        }
        if (context instanceof Activity) {
            int ˎ = dgm.ˎ((Activity) context);
            if (ˎ == 17) {
                return ˎ(context, "kidscenter_app_name");
            }
            if (ˎ == 18) {
                return ˎ(context, "educenter_app_name");
            }
        }
        return ˊ(context, context.getPackageName());
    }

    private boolean ˏ() {
        if (this.ˋ != null) {
            CheckBox checkBox = (CheckBox) this.ˋ.findViewById(j.ʻʼ);
            if (checkBox != null) {
                return checkBox.isChecked();
            }
        }
        return false;
    }

    private void ˎ(final Context context, final String str, final String str2) {
        if (this.ˏ != null) {
            this.ˏ.ॱ(new cks(this) {
                final /* synthetic */ dws ˏ;

                public void enableNetworking() {
                    dwv.ˊ(context, "deeplinkDialog");
                    if (this.ˏ.ˏ()) {
                        Set ᐝ = euf.ˎ().ᐝ();
                        if (ᐝ == null) {
                            ᐝ = new HashSet();
                        }
                        ᐝ.add(str);
                        euf.ˎ().ˋ(ᐝ);
                    }
                    if (this.ˏ.ॱ != null) {
                        this.ˏ.ॱ.aj_();
                    }
                }

                public void upgrade() {
                    dwv.ˊ(context, "deeplinkDialog");
                    dgh.ˋ("340302", evg.ˋ(dwv.ˋ(str2), str2, str, dgm.ˎ((Activity) context)));
                    if (this.ˏ.ॱ != null) {
                        this.ˏ.ॱ.ak_();
                    }
                }

                public void ˋ() {
                }
            });
        }
    }
}
